﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IUserBlock" in both code and config file together.
[ServiceContract]
public interface IUserBlock
{
    [OperationContract]
    List<User> GetAllUser();

    [OperationContract]
    void Block(Guid userID,bool status);

    [OperationContract]
    User GetUser(String user, String pass);

    [OperationContract]
    List<User> GetUserByName(String userName);
}

[DataContract]
public class User
{
    Guid userID;
    [DataMember]
    public Guid UserID
    {
        get { return userID; }
        set { userID = value; }
    }


    String userName;
    [DataMember]
    public String UserName
    {
        get { return userName; }
        set { userName = value; }
    }

    String pass;
    [DataMember]
    public String Pass
    {
        get { return pass; }
        set { pass = value; }
    }

    String name;
    [DataMember]
    public String Name
    {
        get { return name; }
        set { name = value; }
    }

    String sex;
    [DataMember]
    public String Sex
    {
        get { return sex; }
        set { sex = value; }
    }

    DateTime birthDay;
    [DataMember]
    public DateTime BirthDay
    {
        get { return birthDay; }
        set { birthDay = value; }
    }

    String address;
    [DataMember]
    public String Address
    {
        get { return address; }
        set { address = value; }
    }

    String country;
    [DataMember]
    public String Country
    {
        get { return country; }
        set { country = value; }
    }

    String email;
    [DataMember]
    public String Email
    {
        get { return email; }
        set { email = value; }
    }

    float socer;
    [DataMember]
    public float Socer
    {
        get { return socer; }
        set { socer = value; }
    }

    bool permisstion;
    [DataMember]
    public bool Permisstion
    {
        get { return permisstion; }
        set { permisstion = value; }
    }

    bool userStatus;
    [DataMember]
    public bool UserStatus
    {
        get { return userStatus; }
        set { userStatus = value; }
    }

    // init User from a User_Table
    public User(User_Table userCopy)
    {
        userID = userCopy.UserID;
        userName = userCopy.Username;
        pass = userCopy.Password;
        name = userCopy.Name;
        sex = userCopy.Sex;
        birthDay = userCopy.Birthday;
        address = userCopy.Address;
        country = userCopy.Country;
        email = userCopy.Email;
        if (userCopy.Score == null)
        {
            socer = 0;
        }
        else
        {
            socer = (float)userCopy.Score;
        }
        permisstion = userCopy.Permission;
        userStatus = userCopy.User_status;
    }
}
